<div class="crumb-wrap">
    <div class="crumb-list"><i class="icon-font"></i><a href="<?=site_url('admini')?>">首页</a>
        <span class="crumb-step">&gt;</span><a class="crumb-name" href="<?=site_url('admini/goods')?>">商品管理</a></span>
        <span class="crumb-step">&gt;</span><span>商品图片</span>
    </div>
</div>

<div class="search-wrap">
    <div class="search-content">
        
    </div>
</div>
<iframe id="iframepage" name="add_stores" src="<?=site_url('admini/image/get_menu?gid='.$res['id'])?>" frameborder="0" border="0"  marginwidth="0" style="width: 100%;height:300px"></iframe>
<script type="text/javascript" src="<?php echo base_url('public/plupload/js/plupload.full.min.js'); ?>" ></script>
<script type="text/javascript" src="<?php echo base_url('public/plupload/js/jquery.plupload.queue/jquery.plupload.queue.js'); ?>" ></script>
<script type="text/javascript" src="<?php echo base_url('public/plupload/js/i18n/zh_CN.js'); ?>" ></script>
<link rel="stylesheet" href="<?php echo base_url('public/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css'); ?>" />


<div id="uploader">
</div>



<script type="text/javascript">
//加载菜单
$.get("<?=site_url('admini/widget/goods_menu?menu=6&gid=4')?>",function(data){
    $("#goods_menu").html(data);
},'text');

$(function() {
    var photos = Array(); // 用于存放照片信息
    // 设置参数，初始化Plupload

    $("#uploader").pluploadQueue({

        runtimes : 'html5,silverlight,html4',

        url : "http://up.qiniu.com/",

        chunk_size : '512kb',

        rename : true,

        dragdrop: true,

        filters : {

            max_file_size : '1mb',

            mime_types: [

                {title : "Image files", extensions : "jpg,jpeg,gif,png"},

                //{title : "Zip files", extensions : "zip"}

            ]

        },

        multipart: true,

        multipart_params: {

            'token': '<?php echo $upToken;?>', //token，需要从服务器获取

        },

        flash_swf_url : '<?php echo base_url("public/plupload/js/Moxie.swf"); ?>'

    });

 

    var uploader = $('#uploader').pluploadQueue();

    //上传文件之前触发

    uploader.bind('BeforeUpload', function(uploader, file){

        var file_ext = file.name.substr(file.name.lastIndexOf(".")); // 图片后缀

        //指定文件的名称，如果不设置，七牛会默认将文件的hash值作为文件的名字

        uploader.settings.multipart_params.key = parseInt(new Date().valueOf()/1000) + '-' + parseInt(Math.random()*8999 + 1000) +file_ext;

    });

    //成功上传一个文件后触发

    uploader.bind('FileUploaded', function(uploader, file, responseObject) {

        //将七牛返回的json数据转换成对象

        var res = eval('('+responseObject.response+')'); 

        var a = JSON.stringify(res, undefined, 2);

        alert(a);

        // //组合文件信息

        // var photo = new Object();

        // //因为在数据库中，我用字段名name来存储文件名，用path来存储七牛上的文件名

        // //所以这里的photo对象属性为name和path，如果你用的字段名和我的不一样，请自行修改

        // photo.name = file.name; // 上传之前的图片名称

        // photo.path = res.key; // 保存后的图片名称(含前缀)

        // photos.push(photo); //将对象压入到photos数组

 

    });

    //全部文件上传完成后触发

    uploader.bind('UploadComplete', function(uploader, file){

        //文件全部成功上传后，将数据传递给CI框架进行处理

        // $.ajax({

        //     url: "<?php echo site_url('photo/save'); ?>", //ci框架处理地址

        //     type: "POST",

        //     data: {files:JSON.stringify(photos)},

        //     success: function(msg){

        //         alert(msg);

        //     }

        // });

    });

});

</script>